const { MongoClient } = require('mongodb')

const uri = 'mongodb://localhost:27017'

const client = new MongoClient(uri)

/* async function run () {
  try {
    const database = client.db('demo')
    const articles = database.collection('articles')
    // Query for a movie that has the title 'Back to the Future'
    const query = { title: 'Back to the Future' }
    const article = await articles.findOne(query)
    console.log(article)
  } finally {
    // Ensures that the client will close when you finish/error
    await client.close()
  }
}
run().catch(console.dir) */

const articlesCollection = client.db('demo').collection('articles')

module.exports = articlesCollection
